package com.aspose.cells;

import java.util.ArrayList;

class zcd extends zbz {
   private ArrayList a;

   zcd() {
      this.c(233);
   }

   static byte[] a(int var0, int var1, int var2) {
      byte[] var3 = new byte[20];
      var3[0] = 9;
      var3[2] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var0), 0, var3, 4, 4);
      byte var4 = 8;
      var3[var4] = 12;
      int var5 = var4 + 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, var3, var5, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var3, var5 + 2, 2);
      var5 += 4;
      var3[var5] = 1;
      var3[var5 + 2] = 24;
      var5 += 4;
      return var3;
   }

   void a(byte[] var1) throws Exception {
      com.aspose.cells.b.a.d.zh var2 = new com.aspose.cells.b.a.d.zh(var1);
      com.aspose.cells.b.a.b.za var3 = new com.aspose.cells.b.a.b.za(com.aspose.cells.b.a.b.zj.a((com.aspose.cells.b.a.d.zm)var2));
      int var4 = var3.i();
      int var5 = var3.h();
      int var6 = (var4 & '\uffff') * 3;
      int var7 = var6 % 4;
      if (var7 != 0) {
         var7 = 4 - var7;
         var6 += var7;
      }

      int var8 = var6 * (var5 & '\uffff') + 12;
      short var9 = 8212;
      int var11 = 20;
      Color var10;
      int var13;
      if (var8 < var9) {
         this.c = new byte[var8 + 8];
         this.a((short)this.c.length);
         System.arraycopy(a(var8, var4, var5), 0, this.c, 0, 20);

         for(int var22 = (var5 & '\uffff') - 1; var22 >= 0; --var22) {
            for(var13 = 0; var13 < (var4 & '\uffff'); ++var13) {
               var10 = var3.a(var13, var22);
               if (var10.toArgb() == 0) {
                  var10 = Color.getWhite();
               }

               this.c[var11++] = com.aspose.cells.a.c.zh.d(var10);
               this.c[var11++] = com.aspose.cells.a.c.zh.c(var10);
               this.c[var11++] = com.aspose.cells.a.c.zh.b(var10);
            }

            if (var7 != 0) {
               for(var13 = 0; var13 < var7; ++var13) {
                  this.c[var11++] = 0;
               }
            }
         }

      } else {
         this.c = a(var8, var4, var5);
         this.b(20);
         this.a = new ArrayList();
         byte[] var12 = new byte[var9 - 12];
         var8 -= 12;
         var11 = 0;

         for(var13 = (var5 & '\uffff') - 1; var13 >= 0; --var13) {
            int var14;
            for(var14 = 0; var14 < (var4 & '\uffff'); ++var14) {
               var10 = var3.a(var14, var13);
               int var15 = var10.toArgb();
               int var16 = var15 >> 24 & 255;
               int var17 = var15 >> 16 & 255;
               int var18 = var15 >> 8 & 255;
               int var19 = var15 & 255;
               if (var16 != 255) {
                  double var20 = (double)((float)(255 - var16) / 255.0F);
                  var17 += (int)((double)(255 - var17) * var20);
                  var18 += (int)((double)(255 - var18) * var20);
                  var19 += (int)((double)(255 - var19) * var20);
               }

               var12[var11++] = (byte)var19;
               if (var11 == var12.length) {
                  com.aspose.cells.b.a.a.ze.a(this.a, (Object)var12);
                  var8 -= var12.length;
                  var12 = new byte[var8 > var9 ? var9 : var8];
                  var11 = 0;
               }

               var12[var11++] = (byte)var18;
               if (var11 == var12.length) {
                  com.aspose.cells.b.a.a.ze.a(this.a, (Object)var12);
                  var8 -= var12.length;
                  var12 = new byte[var8 > var9 ? var9 : var8];
                  var11 = 0;
               }

               var12[var11++] = (byte)var17;
               if (var11 == var12.length) {
                  com.aspose.cells.b.a.a.ze.a(this.a, (Object)var12);
                  var8 -= var12.length;
                  var12 = new byte[var8 > var9 ? var9 : var8];
                  var11 = 0;
               }
            }

            if (var7 != 0) {
               for(var14 = 0; var14 < var7; ++var14) {
                  var12[var11++] = 0;
                  if (var11 == var12.length) {
                     com.aspose.cells.b.a.a.ze.a(this.a, (Object)var12);
                     var8 -= var12.length;
                     var12 = new byte[var8 > var9 ? var9 : var8];
                     var11 = 0;
                  }
               }
            }
         }

         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var12);
      }
   }

   void a(zqa var1) throws Exception {
      var1.a(this.f());
      if (this.a == null) {
         var1.a(this.d());
         var1.a(this.c);
      } else {
         byte[] var2 = (byte[])((byte[])this.a.get(0));
         var1.a((short)(this.d() + var2.length));
         var1.a(this.c);
         var1.a(var2);

         for(int var3 = 1; var3 < this.a.size(); ++var3) {
            var1.a((short)60);
            var2 = (byte[])((byte[])this.a.get(var3));
            var1.a((short)var2.length);
            var1.a(var2);
         }
      }

   }
}
